package net.cloudsun.tree.avl;

import net.cloudsun.tree.orderbinary.OrderBinaryTree;

/**
 * @author Ryan
 * @since
 */
public class AVLTree<T extends Comparable<T>> extends OrderBinaryTree<T> {

    public AVLTree() {
    }

    public <T extends Comparable<T>> AVLTree(AVLNode<T> node) {
        setRoot(node);
    }

    @Override
    protected AVLNode<T> createNode(T t) {
        return new AVLNode<>(t);
    }

    @Override
    public void delete(T t) {
        super.delete(t);
        if (root != null) {
            ((AVLNode<T>)this.root).fixToBalance();
        }
    }
}
